﻿#region zh-CHS 2006 - 2010 DemoSoft 团队 | en 2006-2010 DemoSoft Team

//     NOTES
// ---------------
//
// This file is a part of the MMOSE(Massively Multiplayer Online Server Engine) for .NET.
//
//                              2006-2010 DemoSoft Team
//
//
// First Version : by H.Q.Cai - mailto:caihuanqing@hotmail.com

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Lesser General Public License as published
 *   by the Free Software Foundation; either version 2.1 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

#region zh-CHS 包含名字空间 | en Include namespace
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Demo.Mmose.Core.Common.SafeCollections;
using System.Collections;
using System.Threading;
using Demo.Mmose.Core.Util;
#endregion

namespace Demo.Mmose.Core.Entity.Suit.Quest
{

    /// <summary>
    /// 
    /// </summary>
    public class QuestManager<ObjectT> : IEnumerable<Quest>
    {

        #region zh-CHS 共有方法 | en Public Methods

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private SafeDictionary<long, Quest> m_QuestDictionary = new SafeDictionary<long, Quest>();
        #endregion
        /// <summary>
        /// 
        /// </summary>
        /// <param name="baseTaxiNode"></param>
        public void Add( long questId, Quest quest )
        {
            if ( quest == null )
                throw new ArgumentNullException( "quest", "QuestManager.Add(...) - quest == null error!" );

            m_QuestDictionary.Add( questId, quest );
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public Quest FindQuestOnId( long questId )
        {
            return m_QuestDictionary.GetValue( questId );
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public void Remove( long questId )
        {
            m_QuestDictionary.Remove( questId );
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="spellId"></param>
        /// <returns></returns>
        public bool Contains( long questId )
        {
            return m_QuestDictionary.ContainsKey( questId );
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="iQuestId"></param>
        public void Clear()
        {
            m_QuestDictionary.Clear();
        }

        /// <summary>
        /// 
        /// </summary>
        public Quest[] ToArray()
        {
            return m_QuestDictionary.ToArrayValues();
        }

        #endregion

        #region zh-CHS 接口实现 | en Interface Implementation
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public IEnumerator<Quest> GetEnumerator()
        {
            Quest[] tempSpellArray = this.ToArray();
            if ( tempSpellArray == null )
                yield break;

            for ( int iIndex = 0; iIndex < tempSpellArray.Length; iIndex++ )
                yield return tempSpellArray[iIndex];
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }
        #endregion

    }

    /// <summary>
    /// 
    /// </summary>
    public class QuestManager : QuestManager<object>
    {

    }
}
#endregion